package com.cooud.order.interceptor;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: DongGuoZhen
 * @Date: 2025/03/16/15:02
 * @Description:
 */
@Component
public class TokenRequestInterceptor implements RequestInterceptor {
    /**
     * 请求拦截器
     * @param requestTemplate
     */
    @Override
    public void apply(RequestTemplate requestTemplate) {
//        requestTemplate为请求的详细信息
        System.out.println("拦截器被调用");
        requestTemplate.header("X-Token", UUID.randomUUID().toString()); // 给请求添加一个自定义的header
    }
}
